<template>
    <div>
        <h2>登录</h2>

        <table>
            <tr>
                <td>用户名</td>
                <td><input type="text" v-model="user.name"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="user.pwd"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" value="登录" @click="login"></td>
            </tr>
        </table>



    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
let router = useRouter();

let user = reactive({
    name: '',
    pwd: ''
});

const login = () => {
    axios({
        url: 'https://localhost:7025/api/User/Login',
        method: 'get',
        params: user
    })
        .then(res => {
            if (res.data > 0) {
                alert('登录成功');
                router.push('/dengList');
            } else {
                alert('密码错误')
            }
        })
}


</script>

<style scoped></style>